{include file='public:header-css'/}
<body>
<div class="lyear-layout-web">
    <div class="lyear-layout-container">
        <!--左侧导航-->
        {include file='public:left-menu'/}
        <!--End 左侧导航-->
        <!--头部信息-->
        {include file='public:nav-header' title="会员管理" subTitle="添加会员"/}
        <!--End 头部信息-->

        <!--页面主要内容-->
        <main class="lyear-layout-content">
            <div class="container-fluid">
                <div class="row">
                    <div class="col-lg-12">
                        <div class="card">
                            <div class="card-body">
                                <form method="post" id="submit-form" class="">
                                    <div class="form-group row">
                                        <div class="col-md-4">
                                            <label class="form-title"><em class="require">*</em>手机号码</label>
                                            <input type="text" class="form-control" name="mobile" placeholder="请输入手机号码"/>
                                            <small class="help">会员手机号码</small>
                                            <span class="error" id="err_mobile"></span>
                                        </div>
                                        <div class="col-md-4">
                                            <label class="form-title"><em class="require">*</em>会员姓名</label>
                                            <input type="text" class="form-control" name="realname" placeholder="请输入会员姓名"/>
                                            <small class="help">会员姓名</small>
                                            <span class="error" id="err_realname"></span>
                                        </div>
                                        <div class="col-md-4">
                                            <label class="form-title">会员昵称</label>
                                            <input type="text" class="form-control" name="nickname" placeholder="请输入会员昵称"/>
                                            <small class="help">会员昵称 不填写则默认为手机号</small>
                                            <span class="error" id="err_nickname"></span>
                                        </div>
                                    </div>
                                    <div class="form-group row">
                                        <div class="col-md-6">
                                            <label class="form-title"><em class="require">*</em>登录密码</label>
                                            <input type="password" class="form-control" name="password"
                                                   placeholder="请输入登录密码"/>
                                            <span class="error" id="err_password"></span>
                                        </div>
                                        <div class="col-md-6">
                                            <label class="form-title"><em class="require">*</em>确认密码</label>
                                            <input type="password" class="form-control" name="conpassword"
                                                   placeholder="请输入确认密码"/>
                                            <span class="error" id="err_conpassword"></span>
                                        </div>
                                    </div>
                                    <div class="form-group row">
                                        <div class="col-md-12">
                                            <label class="form-title"><em class="require">*</em>推荐人ID</label>
                                            <input type="text" class="form-control" name="rekey" placeholder="请输入推荐人ID"/>
                                            <span class="error" id="err_rekey"></span>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <div class="col-md-12">
                                            <button type="button" class="btn-theme submit-btn">确定</button>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </main>
        <!--End 页面主要内容-->
    </div>
</div>
<style>
    .dizhi{
        display: flex;
    }
    .dizhi .input-group-select{
        flex: 1;
    }
</style>
<script type="text/javascript">
    $(function () {
        $('.submit-btn').click(function () {
            $('span.error').hide();
            $('.has-error').removeClass('has-error');
            var url = "{:url('User/add_user')}";
            var data = $('#submit-form').serialize();
            public_ajax(url,data,function (data) {
                if (data.code == 1) {
                    showSuccessMsg(data.msg, function () {
                        if (data.data.url) {
                            location.href = data.data.url;
                        }
                    });
                } else if (data.code == 10) {
                    showErrorMsg(data.msg);
                    $.each(data.data.result, function(index, item) {
                        $('#err_' + index).text(item).show();
                        $('#err_' + index).parent().addClass('has-error');
                    });
                } else {
                    showErrorMsg(data.msg);
                }
            });
        });
    });
</script>
</body>
</html>
